package org.gap.web.jsf;

import java.util.List;

import org.gap.dao.AdressesDAO;
import org.gap.dao.CodesPostauxDAO;
import org.gap.dao.PaysDAO;

import org.gap.domain.Adresses;
import org.gap.domain.CodesPostaux;
import org.gap.domain.Pays;

import org.gap.service.CodesPostauxService;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.context.annotation.Scope;

import org.springframework.stereotype.Component;

import org.springframework.transaction.annotation.Transactional;

/**
 * Spring Component that handles CRUD requests for CodesPostaux entities
 * 
 */
@Scope("session")
@Component("CodesPostauxComponent")
public class CodesPostauxComponentImpl implements CodesPostauxComponent {

	/**
	 * Data type variable that provides CRUD operations for CodesPostaux entities
	 * 
	 */
	private CodesPostaux codespostaux;

	/**
	 * DAO injected by Spring that manages Pays entities
	 * 
	 */
	private Pays pays;

	/**
	 * DAO injected by Spring that manages Adresses entities
	 * 
	 */
	private Adresses adresseses;

	/**
	 * DAO injected by Spring that manages Adresses entities
	 * 
	 */
	@Autowired
	private AdressesDAO adressesDAO;

	/**
	 * DAO injected by Spring that manages CodesPostaux entities
	 * 
	 */
	@Autowired
	private CodesPostauxDAO codesPostauxDAO;

	/**
	 * DAO injected by Spring that manages Pays entities
	 * 
	 */
	@Autowired
	private PaysDAO paysDAO;

	/**
	 * Service injected by Spring that provides CRUD operations for CodesPostaux entities
	 * 
	 */
	@Autowired
	private CodesPostauxService codesPostauxService;

	/** 
	 */
	public CodesPostauxComponentImpl() {
	}

	/**
	 * Delete an existing Adresses entity
	 * 
	 */
	@Transactional
	public String deleteCodesPostauxAdresseses(String codespostaux_cdpPays, String codespostaux_cdpCodePostal, String codespostaux_cdpNInsee, String codespostaux_cdpLocalite, Integer related_adresseses_addAdresse) {
		codespostaux = codesPostauxService.deleteCodesPostauxAdresseses(codespostaux_cdpPays, codespostaux_cdpCodePostal, codespostaux_cdpNInsee, codespostaux_cdpLocalite, related_adresseses_addAdresse);

		return "/jsf/codespostaux/viewCodesPostaux.xhtml";
	}

	/**
	 * Edit an existing Adresses entity
	 * 
	 */
	@Transactional
	public String editCodesPostauxAdresseses(String codespostaux_cdpPays, String codespostaux_cdpCodePostal, String codespostaux_cdpNInsee, String codespostaux_cdpLocalite, Integer related_adresseses_addAdresse) {
		adresseses = adressesDAO.findAdressesByPrimaryKey(related_adresseses_addAdresse, -1, -1);
		return "/jsf/codespostaux/adresseses/editAdresseses.xhtml";
	}

	/**
	 * Edit an existing Pays entity
	 * 
	 */
	@Transactional
	public String editCodesPostauxPays(String codespostaux_cdpPays, String codespostaux_cdpCodePostal, String codespostaux_cdpNInsee, String codespostaux_cdpLocalite, String related_pays_pppPays) {
		pays = paysDAO.findPaysByPrimaryKey(related_pays_pppPays, -1, -1);
		return "/jsf/codespostaux/pays/editPays.xhtml";
	}

	/**
	 * Select the CodesPostaux entity for display allowing the user to confirm that they would like to delete the entity
	 * 
	 */
	@Transactional
	public String confirmDeleteCodesPostaux(String cdpPaysKey, String cdpCodePostalKey, String cdpNInseeKey, String cdpLocaliteKey) {
		codespostaux = codesPostauxDAO.findCodesPostauxByPrimaryKey(cdpPaysKey, cdpCodePostalKey, cdpNInseeKey, cdpLocaliteKey);

		return "/jsf/codespostaux/deleteCodesPostaux.xhtml";
	}

	/**
	 * Delete an existing CodesPostaux entity
	 * 
	 */
	@Transactional
	public String deleteCodesPostaux(String cdpPaysKey, String cdpCodePostalKey, String cdpNInseeKey, String cdpLocaliteKey) {
		CodesPostaux codespostaux = codesPostauxDAO.findCodesPostauxByPrimaryKey(cdpPaysKey, cdpCodePostalKey, cdpNInseeKey, cdpLocaliteKey);
		codesPostauxService.deleteCodesPostaux(codespostaux);
		return "/jsf/codespostaux/listCodesPostauxs.xhtml";
	}

	/**
	 * View an existing Adresses entity
	 * 
	 */
	@Transactional
	public String selectCodesPostauxAdresseses(String codespostaux_cdpPays, String codespostaux_cdpCodePostal, String codespostaux_cdpNInsee, String codespostaux_cdpLocalite, Integer related_adresseses_addAdresse) {
		adresseses = adressesDAO.findAdressesByPrimaryKey(related_adresseses_addAdresse, -1, -1);
		return "/jsf/codespostaux/adresseses/viewAdresseses.xhtml";
	}

	/**
	 * Save an existing CodesPostaux entity
	 * 
	 */
	@Transactional
	public String saveCodesPostaux(CodesPostaux codespostaux) {
		codesPostauxService.saveCodesPostaux(codespostaux);
		return "/jsf/codespostaux/listCodesPostauxs.xhtml";
	}

	/**
	 * Delete an existing Pays entity
	 * 
	 */
	@Transactional
	public String deleteCodesPostauxPays(String codespostaux_cdpPays, String codespostaux_cdpCodePostal, String codespostaux_cdpNInsee, String codespostaux_cdpLocalite, String related_pays_pppPays) {
		codespostaux = codesPostauxService.deleteCodesPostauxPays(codespostaux_cdpPays, codespostaux_cdpCodePostal, codespostaux_cdpNInsee, codespostaux_cdpLocalite, related_pays_pppPays);

		return "/jsf/codespostaux/viewCodesPostaux.xhtml";
	}

	/**
	 * Create a new CodesPostaux entity
	 * 
	 */
	@Transactional
	public String newCodesPostaux() {
		codespostaux = new CodesPostaux();

		return "/jsf/codespostaux/createCodesPostaux.xhtml";
	}

	/**
	 * Getter for variable CodesPostaux
	 * 
	 */
	@Transactional
	public CodesPostaux getCodespostaux() {
		return codespostaux;
	}

	/**
	 * Select the child Pays entity for display allowing the user to confirm that they would like to delete the entity
	 * 
	 */
	@Transactional
	public String confirmDeleteCodesPostauxPays(String codespostaux_cdpPays, String codespostaux_cdpCodePostal, String codespostaux_cdpNInsee, String codespostaux_cdpLocalite, String related_pays_pppPays) {
		pays = paysDAO.findPaysByPrimaryKey(related_pays_pppPays);

		return "/jsf/codespostaux/pays/deletePays.xhtml";
	}

	/**
	 * Edit an existing CodesPostaux entity
	 * 
	 */
	@Transactional
	public String editCodesPostaux(String cdpPaysKey, String cdpCodePostalKey, String cdpNInseeKey, String cdpLocaliteKey) {
		codespostaux = codesPostauxDAO.findCodesPostauxByPrimaryKey(cdpPaysKey, cdpCodePostalKey, cdpNInseeKey, cdpLocaliteKey);

		return "/jsf/codespostaux/editCodesPostaux.xhtml";
	}

	/**
	 * Save an existing Pays entity
	 * 
	 */
	@Transactional
	public String saveCodesPostauxPays(String codespostaux_cdpPays, String codespostaux_cdpCodePostal, String codespostaux_cdpNInsee, String codespostaux_cdpLocalite, Pays pays) {
		codespostaux = codesPostauxService.saveCodesPostauxPays(codespostaux_cdpPays, codespostaux_cdpCodePostal, codespostaux_cdpNInsee, codespostaux_cdpLocalite, pays);

		return "/jsf/codespostaux/viewCodesPostaux.xhtml";
	}

	/**
	 * Save an existing Adresses entity
	 * 
	 */
	@Transactional
	public String saveCodesPostauxAdresseses(String codespostaux_cdpPays, String codespostaux_cdpCodePostal, String codespostaux_cdpNInsee, String codespostaux_cdpLocalite, Adresses adresses) {
		codespostaux = codesPostauxService.saveCodesPostauxAdresseses(codespostaux_cdpPays, codespostaux_cdpCodePostal, codespostaux_cdpNInsee, codespostaux_cdpLocalite, adresses);

		return "/jsf/codespostaux/viewCodesPostaux.xhtml";
	}

	/**
	 * View an existing Pays entity
	 * 
	 */
	@Transactional
	public String selectCodesPostauxPays(String codespostaux_cdpPays, String codespostaux_cdpCodePostal, String codespostaux_cdpNInsee, String codespostaux_cdpLocalite, String related_pays_pppPays) {
		pays = paysDAO.findPaysByPrimaryKey(related_pays_pppPays, -1, -1);
		return "/jsf/codespostaux/pays/viewPays.xhtml";
	}

	/**
	 * Get Pays entity by CodesPostaux
	 * 
	 */
	@Transactional
	public Pays getCodesPostauxPays(String cdpPaysKey, String cdpCodePostalKey, String cdpNInseeKey, String cdpLocaliteKey) {
		return codesPostauxDAO.findCodesPostauxByPrimaryKey(cdpPaysKey, cdpCodePostalKey, cdpNInseeKey, cdpLocaliteKey).getPays();
	}

	/**
	 * Create a new Pays entity
	 * 
	 */
	@Transactional
	public String newCodesPostauxPays(String codespostaux_cdpPays, String codespostaux_cdpCodePostal, String codespostaux_cdpNInsee, String codespostaux_cdpLocalite) {
		pays = new Pays();

		return "/jsf/codespostaux/pays/createPays.xhtml";
	}

	/**
	 * Select an existing CodesPostaux entity
	 * 
	 */
	@Transactional
	public String selectCodesPostaux(String cdpPaysKey, String cdpCodePostalKey, String cdpNInseeKey, String cdpLocaliteKey) {
		codespostaux = codesPostauxDAO.findCodesPostauxByPrimaryKey(cdpPaysKey, cdpCodePostalKey, cdpNInseeKey, cdpLocaliteKey);

		return "/jsf/codespostaux/viewCodesPostaux.xhtml";
	}

	/**
	 * Show all CodesPostaux entities
	 * 
	 */
	@Transactional
	public List<CodesPostaux> listCodesPostauxs() {
		return new java.util.ArrayList<CodesPostaux>(codesPostauxService.loadCodesPostauxs());
	}

	/**
	 * Select the child Adresses entity for display allowing the user to confirm that they would like to delete the entity
	 * 
	 */
	@Transactional
	public String confirmDeleteCodesPostauxAdresseses(String codespostaux_cdpPays, String codespostaux_cdpCodePostal, String codespostaux_cdpNInsee, String codespostaux_cdpLocalite, Integer related_adresseses_addAdresse) {
		adresseses = adressesDAO.findAdressesByPrimaryKey(related_adresseses_addAdresse);

		return "/jsf/codespostaux/adresseses/deleteAdresseses.xhtml";
	}

	/**
	 * Getter for variable CodesPostaux
	 * 
	 */
	@Transactional
	public Adresses getAdresseses() {
		return adresseses;
	}

	/**
	 * Show all Adresses entities by CodesPostaux
	 * 
	 */
	@Transactional
	public List<Adresses> listCodesPostauxAdresseses(String cdpPaysKey, String cdpCodePostalKey, String cdpNInseeKey, String cdpLocaliteKey) {
		return new java.util.ArrayList<Adresses>(codesPostauxDAO.findCodesPostauxByPrimaryKey(cdpPaysKey, cdpCodePostalKey, cdpNInseeKey, cdpLocaliteKey).getAdresseses());
	}

	/**
	 * Create a new Adresses entity
	 * 
	 */
	@Transactional
	public String newCodesPostauxAdresseses(String codespostaux_cdpPays, String codespostaux_cdpCodePostal, String codespostaux_cdpNInsee, String codespostaux_cdpLocalite) {
		adresseses = new Adresses();

		return "/jsf/codespostaux/adresseses/createAdresseses.xhtml";
	}

	/**
	 * Getter for variable CodesPostaux
	 * 
	 */
	@Transactional
	public Pays getPays() {
		return pays;
	}

}
